Learn R Programming

ibmdbR (version 1.42.2)

idaQuery, idaScalarQuery: Run an SQL query on the database

Description

Use these functions to run any SQL query on the database and put the results into a data.frame.

Usage

idaQuery(..., as.is=TRUE)

idaScalarQuery(..., as.is=TRUE)

Arguments

...
Any number of query parts which are passed to paste.
as.is
Specifies whether the result columns are to be converted using RODBC type conversions (as.is=FALSE) or left unconverted (as.is=TRUE). For more information about RODBC type conversions, see the descriptions of the functions sqlGetResults an

Value

  • The idaQuery function returns a data frame that contains the result of the specified query. The idaScalarQuery function returns the result of the specified query coerced to a single scalar value.

Details

All parts of the input query are concatenated with paste(..., sep="") and the result is passed to the database.

Examples

Run this code
#idaScalarQuery returns a single value
v <- idaScalarQuery("SELECT COUNT(*) FROM IRIS")

#idaQuery returns a data.frame
df <- idaScalarQuery("SELECT * FROM IRIS")

#idaQuery and idaScalarQuery automatically paste all arguments into a single query
#This is convenient if you use variables

tableName <- "IRIS"
df <- idaQuery("SELECT COUNT(*) FROM ",tableName)

Run the code above in your browser using DataLab